<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //ES5类的表现形式
        //大写是类，小写是函数
        function Person(name,age){
            this.name = name;
            this.age = age;
        }
        Person.prototype.getName = function(){
            console.log(this.name);
        }

        var p = new Person("iwen",20);
        p.getName();

        //ES6类的表现形式:不存在变量提升
        class Person1{
           constructor(name,age){
            this.name = name;
            this.age  = age;
           }
           getName(){
            console.log(this.name);
           }
        }
        var  p = new Person1("dasf",23);
        p.getName();
    </script>
</body>
</html>